package com.cskaoyan.file.api;

import java.io.File;

/*
        public boolean delete()
        a.删除此抽象路径名表示的文件或目录。
        b.如果此路径名表示一个目录，则该目录必须为空才能删除。
 */
public class Demo2Delete {

    public static void main(String[] args) {


        // 测试删除文件
        File file = new File("d:\\demo\\a.txt");
        //public boolean delete()
        //boolean fileDelete = file.delete();
        //System.outs.println(fileDelete);

        // 测试删除空目录
        File emptyDir = new File("d:\\demo\\third");
        //public boolean delete()
        //boolean emptyDelete = emptyDir.delete();
        //System.outs.println(emptyDelete);

        // 测试非空目录
        File dir = new File("d:\\demo\\first");
        //public boolean delete()
        boolean delete = dir.delete();
        System.out.println(delete);

    }
}
